import { Icon } from 'tdesign-icons-vue-next';
import type { FormRule, PrimaryTableCol, SelectProps } from 'tdesign-vue-next';
import { Space } from 'tdesign-vue-next';
import { h } from 'vue';

import { t } from '@/locales';

/**
 * 搜索表单项
 */
export const searchParams: SearchParamsProps[] = [
    {
        label: t('pages.foodType.title'),
        key: 'title',
    },
];

/**
 * 表格列
 */
export const columns: PrimaryTableCol[] = [
    {
        title: t('pages.foodType.title'),
        ellipsis: true,
        align: 'center',
        colKey: 'title',
    },
    {
        title: t('pages.foodType.icon'),
        ellipsis: true,
        align: 'center',
        colKey: 'icon',
    },
    {
        title: t('pages.foodType.remarks'),
        ellipsis: true,
        align: 'center',
        colKey: 'remarks',
    },
];

/**
 * 表单校验规则
 */
export const rules: Record<string, FormRule[]> = {
    icon: [{ required: true, message: t('pages.foodType.required.icon'), type: 'error', trigger: 'all' }],
};

/**
 *  阿里巴巴矢量图标库——json数据
 */
const iconFontArray = {
    id: '4999395',
    name: 'personal_sport',
    font_family: 'iconfont',
    css_prefix_text: 'icon-',
    description: '',
    glyphs: [
        {
            icon_id: '10572190',
            name: 'sharpicons_hot-dog-coke',
            font_class: 'sharpicons_hot-dog-coke',
            unicode: 'e7f5',
            unicode_decimal: 59381,
        },
        {
            icon_id: '10572197',
            name: 'sharpicons_wine-bottle-2',
            font_class: 'sharpicons_wine-bottle-',
            unicode: 'e7f9',
            unicode_decimal: 59385,
        },
        {
            icon_id: '10572212',
            name: 'sharpicons_wine-bottle',
            font_class: 'sharpicons_wine-bottle',
            unicode: 'e7fb',
            unicode_decimal: 59387,
        },
        {
            icon_id: '10572214',
            name: 'sharpicons_coke',
            font_class: 'sharpicons_coke',
            unicode: 'e7fc',
            unicode_decimal: 59388,
        },
        {
            icon_id: '10572215',
            name: 'sharpicons_bread-3',
            font_class: 'sharpicons_bread-',
            unicode: 'e7fa',
            unicode_decimal: 59386,
        },
        {
            icon_id: '10572224',
            name: 'sharpicons_fried-potatoes',
            font_class: 'sharpicons_fried-potatoes',
            unicode: 'e7fe',
            unicode_decimal: 59390,
        },
        {
            icon_id: '10572232',
            name: 'sharpicons_cherries',
            font_class: 'sharpicons_cherries',
            unicode: 'e7fd',
            unicode_decimal: 59389,
        },
        {
            icon_id: '1094',
            name: '手表',
            font_class: 'shoubiao',
            unicode: 'e600',
            unicode_decimal: 58880,
        },
        {
            icon_id: '25139',
            name: '运动',
            font_class: 'yundong',
            unicode: 'e601',
            unicode_decimal: 58881,
        },
        {
            icon_id: '17605426',
            name: '运动',
            font_class: 'yundong1',
            unicode: 'e810',
            unicode_decimal: 59408,
        },
        {
            icon_id: '39594544',
            name: '网球',
            font_class: 'Baseball-g',
            unicode: 'e63e',
            unicode_decimal: 58942,
        },
    ],
};
const iconFontUrl = 'https://at.alicdn.com/t/c/font_4999395_rbo7n6hsymn.js';
export const iconOptions: SelectProps['options'] = iconFontArray.glyphs.map((i) => {
    const value = iconFontArray.css_prefix_text + i.font_class;
    return {
        content: h(Space, {}, [h(Icon, { url: iconFontUrl, name: value, size: 'large' }), h('span', {}, i.name)]),
        label: i.name,
        value,
    };
});

export { iconFontUrl };
